package com.example.demoback.config;
import com.example.demoback.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置类
 * 主要功能：
 * -配置；拦截器
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //注入拦截器对象
    @Autowired
    private TokenInterceptor tokenInterceptor;

    //重写方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/user/getLoginedUser/**")
                .excludePathPatterns("/upload/**");
    }

}
